#!/usr/bin/env bash
#! Encoding UTF-8

COLLECT(){
  echo -e "memory_totol{from=\"free\"} $(free -mt | awk '/Mem/ {print $2}')"
  echo -e "req_total{code=\"200\"} $1" 
  echo -e "req_total{code=\"300\"} $2" 
}

HTTP(){
  echo -e "HTTP/1.1 200 OK\r\n"
  echo "Content-type: text/html"
  echo 
  COLLECT 22 10
}

while true; do HTTP |nc -lp 18080 ;done